﻿using System;
using Budget.Core.Exceptions;

namespace Budget.Core.DomainModel
{
    public class OutcomeOrder : BaseEntity
    {
        public virtual decimal Amount { get; set; }

        public virtual DateTime CreationDate { get; set; }

        public virtual Balance Balance { get; protected set; }

        public virtual Product Product { get; protected set; }

        protected OutcomeOrder()
        {
        }

        public OutcomeOrder(Product product)
        {
            Check.Require<ArgumentNullException>(product != null, "product");

            product.OutcomeOrders.Add(this);
            Product = product;
        }

        public OutcomeOrder(Balance balance, Product product)
        {
            Check.Require<ArgumentNullException>(product != null, "product");
            Check.Require<ArgumentNullException>(balance != null, "balance");

            balance.OutcomeOrders.Add(this);
            Balance = balance;
            product.OutcomeOrders.Add(this);
            Product = product;
        }
    }
}
